﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;
using System.Drawing;
using Website.Logger;
using DAL;
using BOL;
using System.Web.Script.Services;
using System.Web.Services;
using WebLib;
using UtilityExtensions;
using System.Globalization;

namespace UILGestion.AlmacenAdmin
{
    public partial class NotaingresoInsertOPTForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {

            
            if (!IsPostBack)
            {
                 idObra.Value = (string)Request.QueryString["idObra"];
                idAlmacen.Value = (string)Request.QueryString["idAlmacen"];

                 menuObraCtrl1.loadMenuAlmacen(int.Parse(idObra.Value), int.Parse(idAlmacen.Value)); 
                 FormatForm();
            }
            }
            catch (SqlException sqlex)
            {
                WebServerSideSqlError.Log(sqlex);
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
                 "uniqueKey" + DateTime.Now, "alert('" + sqlex.Message.Replace("'", "") + "');", true);


            }
            catch (Exception ex)
            {
                WebServerSideError.Log(ex);
                ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
                 "uniqueKey" + DateTime.Now, "alert('" + ex.Message.Replace("'", "") + "');", true);

            }
        }
        private void FormatForm()
        {

            //--------------------
            int idEmpleadoEmisor = int.Parse(System.Web.HttpContext.Current.Session["idEmpleado"].ToString());
            bool acceso = new DAL.FormularioAcceso().VerificarAcceso(DbUtil.Db,
                idEmpleadoEmisor,
                5, //Nota Ingreso
                int.Parse(idObra.Value),
                2); //Crear
            //------------------------- 
            pnlMain.Visible = true;
        }

        protected void siguienteButton_Click(object sender, EventArgs e)
        {

            string idmotivo = motivosRadioButtonList.SelectedValue;
            if (idmotivo == "1")
            {
                Response.Redirect("../AlmacenAdmin/NotaIngresoInsertOPT2Form.aspx?idAlmacen=" + idAlmacen.Value + "&idObra=" + idObra.Value + "&type=A&idMotivo=" + idmotivo);
            }
            if (idmotivo == "2")
            {
            Response.Redirect("../AlmacenAdmin/NotaIngresoInsertForm.aspx?idAlmacen="+ idAlmacen.Value+"&idObra=" + idObra.Value + "&type=A&idMotivo=" + idmotivo);
            }
            if (idmotivo == "11")
            {
                Response.Redirect("../AlmacenAdmin/NotaIngresoInsertOPT2Form.aspx?idAlmacen=" + idAlmacen.Value + "&idObra=" + idObra.Value + "&type=A&idMotivo=" + idmotivo);
            }
        }

        protected void motivosRadioButtonList_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}